package models

import (
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

type User struct {
	Id    int
	Name  string
	Pwd   string
	Role  string
	Level string
	ImgId string
}
type Article struct {
	Id      int
	Uid     int
	Title   string
	Content string
	Path    string
	Deploy  bool
}
type Image struct {
	Id   int
	Uid  int
	Name string
	Path string
}

//id 表示Book 的页码
type Book struct {
	Id       int
	Uid      int
	HomePage string
	Title    string
	Content  string
	ImgId    string
	Deploy   string
}

//video database set
type Video struct {
	Id       int
	Uid      int
	Name     string
	Path     string
	Poster   string
	Type     string
	Duration int
	Deploy   int
}

//subcase struct
type SubCase struct {
	Id          int
	Uid         int
	Name        string
	Abstract    string
	TechPrepare string
	Process     string
	Display     int
}
type ComCase struct {
	Id          int
	Uid         int
	Name        string
	Abstract    string
	TechPrepare string
	Process     string
	Display     int
}

//子案例与图片的一对多关系
//SRI： subcase relation imges
type SRI struct {
	Id    int
	SubId int
	ImgId int
}
type CRI struct {
	Id    int
	ComId int
	ImgId int
}

//子案例与video的一对多关系
type SRV struct {
	Id    int
	SubId int
	VidId int
}
type CRV struct {
	Id      int
	ComId   int
	VidId   int
	Display int
}

func init() {
	orm.RegisterDataBase("default", "mysql", "yuanshanshan:150318yss@tcp(47.104.96.13:3306)/test?charset=utf8")
	orm.RegisterModel(new(User), new(Article), new(Image), new(Book), new(Video), new(SubCase), new(ComCase), new(SRI), new(CRI), new(SRV), new(CRV))
	orm.RunSyncdb("default", false, true)
}
